package com.reptile.controller;


import com.common.pojo.Result;
import com.reptile.dto.NewsDTO;
import com.reptile.handle.YsNewsHandle;
import com.reptile.service.YsNewsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 测试项目是否运行
 * @author songyafei
 */
@Api(value = "查询新闻信息")
@RestController
@RequestMapping("news")
@RequiredArgsConstructor
public class NewsController {

    private final YsNewsService ysNewsService;

    @Resource
    private YsNewsHandle ysNewsHandle;

    @PostMapping("/query")
    @ApiOperation(value = "查询新闻数据",notes = "查询")
    public Result<?> query(@RequestBody NewsDTO newsDTO) throws Exception {
        Result result = new Result();
        return result.OK(ysNewsService.queryNews(newsDTO));
    }


    @GetMapping("/clear")
    @ApiOperation(value = "清理重复的新闻数据",notes = "清理数据")
    public Result<?> clear() throws Exception {
        Result result = new Result();
        return result.OK(ysNewsService.deleteRepeatData());
    }

    @GetMapping("/leiF")
    @ApiOperation(value = "测试雷锋网",notes = "测试雷锋网")
    public Result<?> leiF() throws Exception {
        Result result = new Result();
        ysNewsHandle.LeiFIndustryNewsExecute();
        return result.OK(true);
    }

    @GetMapping("/PP")
    @ApiOperation(value = "测试澎湃网",notes = "测试澎湃网")
    public Result<?> PP() throws Exception {
        Result result = new Result();
        ysNewsHandle.PPaiNewsExecute();
        return result.OK(true);
    }
}
